home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 June / MacFormat 25.iso / Shareware City / Developers / macgzip_03b2-src / macos / Posix / Posix Includes / ansi.h next >
Encoding:
C/C++ Source or Header  |  1994-10-15  |  1.7 KB  |  59 lines  |  [TEXT/KAHL]

  1. /* The <ansi.h> header checks whether the compiler claims conformance to ANSI
  2.  * Standard C. If so, the symbol _ANSI is defined as 1, otherwise it is 
  3.  * defined as 0.  Based on the result, a macro
  4.  *
  5.  *    _PROTOTYPE(function, params)
  6.  *
  7.  * is defined.  This macro expands in different ways, generating either
  8.  * ANSI Standard C prototypes or old-style K&R (Kernighan & Ritchie) 
  9.  * prototypes, as needed.  Finally, some programs use _CONST, _VOIDSTAR etc
  10.  * in such a way that they are portable over both ANSI and K&R compilers.
  11.  * The appropriate macros are defined here.
  12.  */
  13.  
  14. #pragma once
  15.  
  16. /* ANSI C requires __STDC__ to be defined as 1 for an ANSI C compiler.
  17.  * Some half-ANSI compilers define it as 0.  Get around this here.
  18.  */
  19.  
  20. #define _ANSI              0    /* 0 if compiler is not ANSI C, 1 if it is */
  21.  
  22. #ifdef __STDC__            /* __STDC__ defined for (near) ANSI compilers*/
  23. #if __STDC__ == 1        /* __STDC__ == 1 for conformant compilers */
  24. #undef _ANSI            /* get rid of above definition */
  25. #define _ANSI              1    /* _ANSI = 1 for ANSI C compilers */
  26. #endif
  27. #endif
  28.  
  29. #ifdef THINK_C
  30. #undef _ANSI
  31. #define _ANSI 1
  32. #endif /* THINK_C */
  33.  
  34. /* At this point, _ANSI has been set correctly to 0 or 1. Define the
  35.  * _PROTOTYPE macro to either expand both of its arguments (ANSI prototypes),
  36.  * only the function name (K&R prototypes).
  37.  */
  38.  
  39. #if _ANSI
  40. #define    _PROTOTYPE(function, params)    function params
  41. #define    _VOIDSTAR    void *
  42. #define    _VOID        void
  43. #define    _CONST        const
  44. #define    _VOLATILE    volatile
  45. #ifndef _SIZET
  46. #  define _SIZET        size_t
  47. #endif
  48.  
  49. #else
  50.  
  51. #define    _PROTOTYPE(function, params)    function()
  52. #define    _VOIDSTAR    void *
  53. #define    _VOID        void
  54. #define    _CONST
  55. #define    _VOLATILE
  56. #define _SIZET        int
  57.  
  58. #endif /* _ANSI */
  59.